#! /usr/bin/env python3

#Author: Ahmed Abdulshafy
#Time: Tuesday, 13 August 2013, 11:20 PM
#Last Modification: Tuesday, 13 August 2013, 11:37 PM

import cdr_rate, cdr_parse, cdr_db_mysql
import sys

def cdr_print(cdr_list):
	print cdr_list

cdr_db = cdr_db_mysql.cdrMySQL()

for f in sys.argv[1:]:
	(cdr_list, err) = cdr_parse.cdr_parse(f)
	for cdr in cdr_list:
		cost = cdr_rate.rate(cdr)
		cdr["money"] = cost
		cdr_print(cdr)
		cdr_db.cdr_wr(cdr)





#cdr_print(cdr_db.cdr_rd())